package com.taorenqi.business.adapter;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.taorenqi.business.R;
import com.taorenqi.business.helper.RecyclerViewHolder;
import com.taorenqi.data.entity.mine.MoneyDetailEntity;
import com.taorenqi.data.entity.mine.PopularityEntity;

import java.util.List;

/**
 * Created by eric on 2017/9/8.
 */

public class PopularityAdapter extends BaseQuickAdapter<PopularityEntity,RecyclerViewHolder> {

    private int flag = 0;
    public PopularityAdapter(List<PopularityEntity> commonEntityList) {
        super(R.layout.item_recyclerview_money_detail,commonEntityList);

    }
    @Override
    protected void convert(final RecyclerViewHolder helper, PopularityEntity item) {
        if (item != null){

            helper
                    .setText(R.id.money_detail_time,item.getAdddate())
                    .setText(R.id.money_detail_type,"收支类型："+ item.getPoints_typename())
                    .setText(R.id.money_detail_number,item.getPoints()+ "")
                    .setText(R.id.money_detail_deal_type,item.getPoints_typename())
                    .setText(R.id.money_detail_deal_number, item.getShop_rechage_money())
                    .addOnClickListener(R.id.money_detail_check)
            ;

            if (item.getShop_rechage_money() == null || "".equals(item.getShop_rechage_money())){
                helper.setText(R.id.money_detail_deal_id,item.getShop_rechage_number());
            }else {
                helper.setText(R.id.money_detail_deal_id,"交易号：" + item.getShop_rechage_number());
            }
            helper.getView(R.id.money_detail_check).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (flag == 0){
                        helper.getView(R.id.money_detail_ll).setVisibility(View.VISIBLE);
                        helper.setText(R.id.money_detail_check,"收起备注");
                        flag = 1;
                    }else if (flag == 1){
                        helper.getView(R.id.money_detail_ll).setVisibility(View.GONE);
                        helper.setText(R.id.money_detail_check,"查看备注");
                        flag = 0;
                    }
                }
            });
        }
    }
}
